"""
Case Type   : cm_ctl
Case Name   : 查看cm_ctl帮助信息
Create At   : 2023/03/24
Owner       : opentestcase012
Description :
    1.查看cm_ctl帮助信息
Expect      :
    1.帮助信息显示正确，有cm_ctl pause/resume相关内容
History     :
"""
import os
import time
import unittest

from testcase.utils.CommonSH import CommonSH
from testcase.utils.Constant import Constant
from testcase.utils.Logger import Logger

primary_sh = CommonSH('PrimaryDbUser')


# @unittest.skipIf(2 != primary_sh.get_node_num(), '非1+2环境不执行')
class DefinedResource(unittest.TestCase):
    def setUp(self):
        self.log = Logger()
        self.log.info(f'----{os.path.basename(__file__)} start----')
        self.constant = Constant()
        self.primary_sh = CommonSH('PrimaryDbUser')

    def test_cm(self):
        text = '----step1:查看cm_ctl帮助信息; ' \
               'expect:帮助信息显示正确，有cm_ctl pause/resume相关内容----'
        self.log.info(text)
        cmd_list = ['-?', '--help']
        for cmd in cmd_list:
            cm_ctl_res = self.primary_sh.exec_cm_ctl(cmd)
            self.assertIn('cm_ctl pause', cm_ctl_res, '执行失败:' + text)
            self.assertIn('cm_ctl resume', cm_ctl_res, '执行失败:' + text)

    def tearDown(self):
        self.log.info('-----无需清理环境-----')
        self.log.info(f'----{os.path.basename(__file__)} finish----')
